{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Local Deep Research API Tutorial\n",
    "\n",
    "This notebook demonstrates how to use the Local Deep Research API to programmatically conduct research."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Basic Imports\n",
    "\n",
    "First, import the main functions from the package:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from local_deep_research.api import quick_summary, generate_report"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generating a Quick Summary\n",
    "\n",
    "The `quick_summary` function allows you to quickly research a topic and get a summary of findings."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:local_deep_research.api.research_functions:Generating quick summary for query: advances in fusion energy\n",
      "INFO:local_deep_research.config.search_config:Creating search engine with tool: wikipedia\n",
      "INFO:local_deep_research.config.search_config:Search config: tool=wikipedia, max_results=10, time_period=all\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Creating search engine for tool: wikipedia with params: dict_keys(['max_results', 'llm', 'max_filtered_results'])\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Creating wikipedia with filtered parameters: dict_keys(['max_results', 'include_content', 'max_filtered_results'])\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Successfully created search engine of type: WikipediaSearchEngine\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Engine has 'run' method: <bound method BaseSearchEngine.run of <local_deep_research.web_search_engines.engines.search_engine_wikipedia.WikipediaSearchEngine object at 0x7576197be270>>\n",
      "INFO:local_deep_research.config.search_config:Successfully created search engine of type: WikipediaSearchEngine\n",
      "INFO:local_deep_research.search_system:Initializing AdvancedSearchSystem with strategy_name='parallel'\n",
      "INFO:local_deep_research.search_system:Creating ParallelSearchStrategy instance\n",
      "INFO:local_deep_research.search_system:Created strategy of type: ParallelSearchStrategy\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Starting parallel research on topic: advances in fusion energy\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generating follow-up questions...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Getting LLM with model: llama-3.3-70b-instruct, temperature: 0.7, provider: openai_endpoint\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generated 3 follow-up questions\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Generated questions: ['What are the latest breakthroughs in fusion energy research and development as of 2025, including advancements in tokamak and stellarator designs?', 'How have recent innovations in materials science and superconducting technologies impacted the efficiency and feasibility of commercial fusion power plants?', 'What are the current trends and projections for the commercialization of fusion energy, including timelines, cost estimates, and potential applications in the global energy market?']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: advances in fusion energy\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the latest breakthroughs in fusion energy research and development as of 2025, including advancements in tokamak and stellarator designs?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: How have recent innovations in materials science and superconducting technologies impacted the efficiency and feasibility of commercial fusion power plants?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the current trends and projections for the commercialization of fusion energy, including timelines, cost estimates, and potential applications in the global energy market?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Fusion power', 'Inertial confinement fusion', 'Magnetic confinement fusion', 'Cold fusion', 'Aneutronic fusion', 'Muon-catalyzed fusion', 'ARC fusion reactor', 'Frank Lucas (Oklahoma politician)', 'Joint European Torus', 'History of nuclear fusion']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 1 Wikipedia results: ['Fusion power']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 1 Wikipedia results: ['Copper']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 6 Wikipedia results: ['Energy development', 'Nuclear power', 'Artificial intelligence', 'Al Gore', '21st century', 'History of YouTube']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 1 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 1 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 6 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "ERROR:local_deep_research.advanced_search_system.filters.cross_engine_filter:Cross-engine filtering error: Extra data: line 1 column 5 (char 4)\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Set questions for 1 iterations\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Formatting final report. Number of detailed findings: 1. Synthesized content length: 3001. Number of question iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Inside format_findings utility. Findings count: 1, Questions iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Formatting 1 detailed finding items.\n",
      "INFO:local_deep_research.utilities.search_utilities:Finished format_findings utility.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Successfully formatted final report.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Added 18 documents to repository\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Advances in fusion energy have been a topic of interest for several decades, with the potential to generate electricity by using heat from nuclear fusion reactions [1]. In a fusion process, two lighter atomic nuclei combine to form a heavier nucleus, while releasing energy, and devices designed to harness this energy are known as fusion reactors [1]. Research into fusion reactors began in the 1940s, but as of 2025, no device has reached net power, although net positive reactions have been achieved [1].\n",
      "\n",
      "There are several approaches to achieving controlled nuclear fusion, including inertial confinement fusion (ICF) [10] and magnetic confinement fusion (MCF) [11]. ICF initiates nuclear fusion reactions by compressing and heating targets filled with fuel, typically containing deuterium and tritium [10]. MCF, on the other hand, uses magnetic fields to confine fusion fuel in the form of a plasma, with the goal of overcoming the electrostatic repulsion between the nuclei [11].\n",
      "\n",
      "Aneutronic fusion is another area of research, which aims to reduce the problems associated with neutron radiation by releasing energy in the form of charged particles, such as protons or alpha particles [13]. This approach has the potential to simplify the conversion of energy into electrical power and reduce the radiation damage to the reactor [13].\n",
      "\n",
      "Several experimental devices have been built to test these approaches, including the Joint European Torus (JET) [17], which was a magnetically confined plasma physics experiment located in the UK. JET began operation in 1983 and achieved several milestones, including the first experiments with tritium in 1991 [17].\n",
      "\n",
      "More recent designs, such as the ARC fusion reactor, aim to achieve an engineering breakeven of three, producing three times the electricity required to operate the machine [15]. The ARC reactor uses high-temperature superconducting magnets and has a conventional advanced tokamak layout [15].\n",
      "\n",
      "While significant progress has been made in fusion research, there is still much to be learned, and the development of commercial fusion power plants is an ongoing effort [4]. The history of nuclear fusion research dates back to the early 20th century, with scientists such as Francis William Aston and Arthur Stanley Eddington contributing to our understanding of the mechanisms by which stars produce energy [18].\n",
      "\n",
      "According to the research [9], fusion processes require fuel, in a state of plasma, and a confined environment with sufficient temperature, pressure, and confinement time. The use of materials with high thermal and electrical conductivity, such as copper [2], is also important in the design of fusion reactors.\n",
      "\n",
      "Overall, advances in fusion energy have the potential to provide a nearly limitless source of clean energy, and ongoing research and development are bringing us closer to achieving this goal [1]. However, significant technical challenges must still be overcome before commercial fusion power plants can be built [4].\n"
     ]
    }
   ],
   "source": [
    "# Research a topic and get a quick summary\n",
    "summary_results = quick_summary(\"advances in fusion energy\")\n",
    "\n",
    "# Print the summary\n",
    "print(summary_results[\"summary\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Customizing Search Parameters\n",
    "\n",
    "You can customize the search process by specifying parameters:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Generate a summary with custom parameters\n",
    "custom_summary = quick_summary(\n",
    "    query=\"renewable energy trends\",\n",
    "    search_tool=\"wikipedia\",  # Use Wikipedia as the search engine\n",
    ")\n",
    "\n",
    "print(f\"Research completed with {custom_summary['iterations']} iterations\")\n",
    "print(\"Questions researched:\")\n",
    "for iteration, questions in custom_summary[\"questions\"].items():\n",
    "    for q in questions:\n",
    "        print(f\"- {q}\")\n",
    "\n",
    "# Print the first 500 characters of the summary\n",
    "print(\"\\nSummary preview:\")\n",
    "print(custom_summary[\"summary\"][:500] + \"...\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generating a Comprehensive Report\n",
    "\n",
    "When you need more detailed research, use the `generate_report` function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:local_deep_research.api.research_functions:Generating comprehensive research report for query: impact of artificial intelligence on healthcare\n",
      "INFO:local_deep_research.config.search_config:Creating search engine with tool: wikipedia\n",
      "INFO:local_deep_research.config.search_config:Search config: tool=wikipedia, max_results=10, time_period=all\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Creating search engine for tool: wikipedia with params: dict_keys(['max_results', 'llm', 'max_filtered_results'])\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Creating wikipedia with filtered parameters: dict_keys(['max_results', 'include_content', 'max_filtered_results'])\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Successfully created search engine of type: WikipediaSearchEngine\n",
      "INFO:local_deep_research.web_search_engines.search_engine_factory:Engine has 'run' method: <bound method BaseSearchEngine.run of <local_deep_research.web_search_engines.engines.search_engine_wikipedia.WikipediaSearchEngine object at 0x76909e956270>>\n",
      "INFO:local_deep_research.config.search_config:Successfully created search engine of type: WikipediaSearchEngine\n",
      "INFO:local_deep_research.search_system:Initializing AdvancedSearchSystem with strategy_name='parallel'\n",
      "INFO:local_deep_research.search_system:Creating ParallelSearchStrategy instance\n",
      "INFO:local_deep_research.search_system:Created strategy of type: ParallelSearchStrategy\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Starting parallel research on topic: impact of artificial intelligence on healthcare\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generating follow-up questions...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Getting LLM with model: llama-3.3-70b-instruct, temperature: 0.7, provider: openai_endpoint\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generated 3 follow-up questions\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Generated questions: ['What are the current advancements and applications of artificial intelligence in healthcare as of 2025, and how are they transforming patient care and medical research?', 'What are the potential benefits and drawbacks of integrating artificial intelligence into healthcare systems, including its impact on diagnosis accuracy, treatment outcomes, and healthcare workforce?', 'How are artificial intelligence and machine learning being used to address specific healthcare challenges, such as disease diagnosis, personalized medicine, and healthcare accessibility, and what are the future directions for AI-driven healthcare innovation?']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: impact of artificial intelligence on healthcare\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the current advancements and applications of artificial intelligence in healthcare as of 2025, and how are they transforming patient care and medical research?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the potential benefits and drawbacks of integrating artificial intelligence into healthcare systems, including its impact on diagnosis accuracy, treatment outcomes, and healthcare workforce?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: How are artificial intelligence and machine learning being used to address specific healthcare challenges, such as disease diagnosis, personalized medicine, and healthcare accessibility, and what are the future directions for AI-driven healthcare innovation?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence in healthcare', 'Generative artificial intelligence', 'Artificial intelligence in mental health', 'Artificial intelligence', 'Artificial intelligence engineering', 'Applications of artificial intelligence', 'Artificial intelligence art', 'Age of artificial intelligence', 'Existential risk from artificial intelligence', 'Artificial intelligence in India']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 3 Wikipedia results: ['Health informatics', 'Health technology', 'Dementia']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence in healthcare', 'Ethics of artificial intelligence', 'Artificial intelligence in mental health', 'Artificial intelligence in India', 'Artificial general intelligence', 'Open-source artificial intelligence', 'Artificial intelligence', 'Cultural competence in healthcare', 'Health technology', 'Big data']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 5 Wikipedia results: ['Applications of artificial intelligence', 'Artificial intelligence in mental health', 'MHealth', 'Big data', 'Imaging informatics']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 3 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 5 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.filters.cross_engine_filter:Cross-engine filtering kept 5 out of 28 results with reordering=True, reindex=True\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Set questions for 1 iterations\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Formatting final report. Number of detailed findings: 1. Synthesized content length: 2727. Number of question iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Inside format_findings utility. Findings count: 1, Questions iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Formatting 1 detailed finding items.\n",
      "INFO:local_deep_research.utilities.search_utilities:Finished format_findings utility.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Successfully formatted final report.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Added 5 documents to repository\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Starting parallel research on topic: impact of artificial intelligence on healthcare Introduction to Artificial Intelligence in Healthcare Definition and Overview Provide a foundational understanding of AI in healthcare\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generating follow-up questions...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing section: Introduction to Artificial Intelligence in Healthcare\n",
      "Researching subsection: Definition and Overview with query: impact of artificial intelligence on healthcare Introduction to Artificial Intelligence in Healthcare Definition and Overview Provide a foundational understanding of AI in healthcare\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generated 3 follow-up questions\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Generated questions: ['What is the current definition and overview of Artificial Intelligence in healthcare as of 2025, including its applications and potential impact on the medical industry?', 'How does Artificial Intelligence transform healthcare systems, and what are the key benefits and challenges of implementing AI in healthcare settings, according to recent research and studies up to 2025?', 'What are the fundamental concepts and techniques of Artificial Intelligence in healthcare, including machine learning, natural language processing, and computer vision, and how are they being used to improve patient outcomes and streamline clinical workflows as of 2025?']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: impact of artificial intelligence on healthcare Introduction to Artificial Intelligence in Healthcare Definition and Overview Provide a foundational understanding of AI in healthcare\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What is the current definition and overview of Artificial Intelligence in healthcare as of 2025, including its applications and potential impact on the medical industry?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: How does Artificial Intelligence transform healthcare systems, and what are the key benefits and challenges of implementing AI in healthcare settings, according to recent research and studies up to 2025?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the fundamental concepts and techniques of Artificial Intelligence in healthcare, including machine learning, natural language processing, and computer vision, and how are they being used to improve patient outcomes and streamline clinical workflows as of 2025?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 2 Wikipedia results: ['Health informatics', 'Big data']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 2 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial general intelligence', 'Artificial intelligence', 'MHealth', 'Healthcare in the United States', 'Regulation of artificial intelligence', 'Timeline of computing 2020–present', 'Big data', 'Google', 'Educational technology', 'National Security Agency']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence in healthcare', 'Artificial intelligence in India', 'Health informatics', 'Timeline of computing 2020–present', 'Google', 'Speech recognition', 'Cognitive behavioral therapy', 'Psychology', 'Internet of things', 'Big data']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence', 'Healthcare in the United States', 'Artificial general intelligence', 'Regulation of artificial intelligence', 'Big data', 'Synthetic biology', 'Robot', 'Alternative medicine', 'Digital health', '5G']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.filters.cross_engine_filter:Cross-engine filtering kept 7 out of 32 results with reordering=True, reindex=True\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Set questions for 1 iterations\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Formatting final report. Number of detailed findings: 1. Synthesized content length: 3527. Number of question iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Inside format_findings utility. Findings count: 1, Questions iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Formatting 1 detailed finding items.\n",
      "INFO:local_deep_research.utilities.search_utilities:Finished format_findings utility.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Successfully formatted final report.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Added 7 documents to repository\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Starting parallel research on topic: impact of artificial intelligence on healthcare Introduction to Artificial Intelligence in Healthcare Current State of AI in Healthcare Set the context for the current applications and advancements\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generating follow-up questions...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Researching subsection: Current State of AI in Healthcare with query: impact of artificial intelligence on healthcare Introduction to Artificial Intelligence in Healthcare Current State of AI in Healthcare Set the context for the current applications and advancements\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generated 3 follow-up questions\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Generated questions: ['What are the current advancements and applications of artificial intelligence in healthcare as of 2025, and how are they transforming the industry?', 'What is the introduction to artificial intelligence in healthcare, including its history, key concepts, and initial applications that have led to its current state of development and implementation?', 'What is the impact of artificial intelligence on healthcare, including its effects on patient outcomes, healthcare costs, and the role of healthcare professionals, and what are the potential future implications of AI integration in healthcare systems?']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: impact of artificial intelligence on healthcare Introduction to Artificial Intelligence in Healthcare Current State of AI in Healthcare Set the context for the current applications and advancements\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the current advancements and applications of artificial intelligence in healthcare as of 2025, and how are they transforming the industry?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What is the introduction to artificial intelligence in healthcare, including its history, key concepts, and initial applications that have led to its current state of development and implementation?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What is the impact of artificial intelligence on healthcare, including its effects on patient outcomes, healthcare costs, and the role of healthcare professionals, and what are the potential future implications of AI integration in healthcare systems?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence in mental health', 'Ethics of artificial intelligence', 'Artificial intelligence in healthcare', 'Music and artificial intelligence', 'Artificial intelligence in India', 'Artificial general intelligence', 'Generative artificial intelligence', 'Open-source artificial intelligence', 'Artificial intelligence', 'AI boom']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Generative artificial intelligence', 'Artificial general intelligence', 'Ethics of artificial intelligence', 'Regulation of artificial intelligence', 'History of artificial intelligence', 'Philosophy of artificial intelligence', 'Artificial intelligence', 'Personalized medicine', 'Robot', 'AI safety']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence in healthcare', 'Applications of artificial intelligence', 'Ethics of artificial intelligence', 'Health equity', 'Artificial general intelligence', 'Virtual reality applications', 'Algorithmic bias', 'Ethics of technology', 'Timeline of computing 2020–present', 'Occupational safety and health']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 10 Wikipedia results: ['Artificial intelligence in mental health', 'Ethics of artificial intelligence', 'History of artificial intelligence', 'Open-source artificial intelligence', 'Artificial intelligence', 'Glossary of artificial intelligence', 'Healthcare in the United States', 'Neural network (machine learning)', 'Personalized medicine', 'Deep learning']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 10 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.filters.cross_engine_filter:Cross-engine filtering kept 6 out of 40 results with reordering=True, reindex=True\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Set questions for 1 iterations\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Formatting final report. Number of detailed findings: 1. Synthesized content length: 3435. Number of question iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Inside format_findings utility. Findings count: 1, Questions iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Formatting 1 detailed finding items.\n",
      "INFO:local_deep_research.utilities.search_utilities:Finished format_findings utility.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Successfully formatted final report.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Added 6 documents to repository\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Starting parallel research on topic: impact of artificial intelligence on healthcare Applications of Artificial Intelligence in Healthcare Medical Subdisciplines Explore the various areas where AI is applied, such as diagnostics and personalized medicine\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generating follow-up questions...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Processing section: Applications of Artificial Intelligence in Healthcare\n",
      "Researching subsection: Medical Subdisciplines with query: impact of artificial intelligence on healthcare Applications of Artificial Intelligence in Healthcare Medical Subdisciplines Explore the various areas where AI is applied, such as diagnostics and personalized medicine\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generated 3 follow-up questions\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Generated questions: ['What are the current applications of artificial intelligence in healthcare, including its impact on medical subdisciplines such as diagnostics, personalized medicine, and patient outcomes as of 2025?', 'How is artificial intelligence being utilized in various healthcare specialties, including radiology, pathology, and oncology, to improve diagnosis, treatment, and patient care in 2025?', 'What are the latest advancements and innovations in artificial intelligence for healthcare, including its potential to enhance medical research, clinical decision support, and personalized medicine, and what are the potential benefits and challenges of these developments as of 2025?']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: impact of artificial intelligence on healthcare Applications of Artificial Intelligence in Healthcare Medical Subdisciplines Explore the various areas where AI is applied, such as diagnostics and personalized medicine\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the current applications of artificial intelligence in healthcare, including its impact on medical subdisciplines such as diagnostics, personalized medicine, and patient outcomes as of 2025?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: How is artificial intelligence being utilized in various healthcare specialties, including radiology, pathology, and oncology, to improve diagnosis, treatment, and patient care in 2025?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Getting Wikipedia page previews for query: What are the latest advancements and innovations in artificial intelligence for healthcare, including its potential to enhance medical research, clinical decision support, and personalized medicine, and what are the potential benefits and challenges of these developments as of 2025?\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 2 Wikipedia results: ['Telehealth', 'Health informatics']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 1 Wikipedia results: ['Artificial intelligence in healthcare']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 1 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 2 Wikipedia results: ['Artificial intelligence in healthcare', 'Ethics of technology']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 2 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Found 3 Wikipedia results: ['Artificial intelligence', 'Timeline of computing 2020–present', '2022 in science']\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 2 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:local_deep_research.web_search_engines.engines.search_engine_wikipedia:Successfully created 3 previews from Wikipedia\n",
      "INFO:local_deep_research.web_search_engines.search_engine_base:Returning snippet-only results as per config\n",
      "INFO:httpx:HTTP Request: POST https://api.ai.it.ufl.edu/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Set questions for 1 iterations\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Formatting final report. Number of detailed findings: 1. Synthesized content length: 3455. Number of question iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Inside format_findings utility. Findings count: 1, Questions iterations: 1\n",
      "INFO:local_deep_research.utilities.search_utilities:Formatting 1 detailed finding items.\n",
      "INFO:local_deep_research.utilities.search_utilities:Finished format_findings utility.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Successfully formatted final report.\n",
      "INFO:local_deep_research.advanced_search_system.findings.repository:Added 8 documents to repository\n",
      "INFO:local_deep_research.advanced_search_system.strategies.parallel_search_strategy:Starting parallel research on topic: impact of artificial intelligence on healthcare Applications of Artificial Intelligence in Healthcare Mental Health Applications Discuss the role of AI in addressing mental health concerns, including diagnosis and treatment planning\n",
      "INFO:local_deep_research.advanced_search_system.questions.standard_question:Generating follow-up questions...\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Researching subsection: Mental Health Applications with query: impact of artificial intelligence on healthcare Applications of Artificial Intelligence in Healthcare Mental Health Applications Discuss the role of AI in addressing mental health concerns, including diagnosis and treatment planning\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[38;5;66;03m# Generate a comprehensive report\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m report \u001b[38;5;241m=\u001b[39m \u001b[43mgenerate_report\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mimpact of artificial intelligence on healthcare\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m      3\u001b[0m \u001b[43m    \u001b[49m\u001b[43miterations\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m                  \u001b[49m\n\u001b[1;32m      4\u001b[0m \u001b[43m    \u001b[49m\u001b[43mquestions_per_iteration\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m      \u001b[49m\n\u001b[1;32m      5\u001b[0m \u001b[43m    \u001b[49m\u001b[43msearches_per_section\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m      6\u001b[0m \u001b[43m    \u001b[49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mopenai_endpoint\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mllama-3.3-70b-instruct\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mopenai_endpoint_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhttps://api.ai.it.ufl.edu/v1/\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msearch_tool\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mwikipedia\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m      7\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m      9\u001b[0m \u001b[38;5;66;03m# Print report metadata\u001b[39;00m\n\u001b[1;32m     10\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mReport metadata:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/api/research_functions.py:165\u001b[0m, in \u001b[0;36mgenerate_report\u001b[0;34m(query, output_file, progress_callback, searches_per_section, **kwargs)\u001b[0m\n\u001b[1;32m    159\u001b[0m \u001b[38;5;66;03m# Generate the structured report\u001b[39;00m\n\u001b[1;32m    160\u001b[0m report_generator \u001b[38;5;241m=\u001b[39m IntegratedReportGenerator(\n\u001b[1;32m    161\u001b[0m     search_system\u001b[38;5;241m=\u001b[39msystem,\n\u001b[1;32m    162\u001b[0m     llm\u001b[38;5;241m=\u001b[39msystem\u001b[38;5;241m.\u001b[39mmodel,\n\u001b[1;32m    163\u001b[0m     searches_per_section\u001b[38;5;241m=\u001b[39msearches_per_section,\n\u001b[1;32m    164\u001b[0m )\n\u001b[0;32m--> 165\u001b[0m report \u001b[38;5;241m=\u001b[39m \u001b[43mreport_generator\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate_report\u001b[49m\u001b[43m(\u001b[49m\u001b[43minitial_findings\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mquery\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    167\u001b[0m \u001b[38;5;66;03m# Save report to file if path is provided\u001b[39;00m\n\u001b[1;32m    168\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m output_file \u001b[38;5;129;01mand\u001b[39;00m report \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcontent\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m report:\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/report_generator.py:51\u001b[0m, in \u001b[0;36mIntegratedReportGenerator.generate_report\u001b[0;34m(self, initial_findings, query)\u001b[0m\n\u001b[1;32m     48\u001b[0m structure \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_determine_report_structure(initial_findings, query)\n\u001b[1;32m     50\u001b[0m \u001b[38;5;66;03m# Step 2: Research and generate content for each section in one step\u001b[39;00m\n\u001b[0;32m---> 51\u001b[0m sections \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_research_and_generate_sections\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m     52\u001b[0m \u001b[43m    \u001b[49m\u001b[43minitial_findings\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstructure\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mquery\u001b[49m\n\u001b[1;32m     53\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     55\u001b[0m \u001b[38;5;66;03m# Step 3: Format final report\u001b[39;00m\n\u001b[1;32m     56\u001b[0m report \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_format_final_report(sections, structure, query)\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/report_generator.py:144\u001b[0m, in \u001b[0;36mIntegratedReportGenerator._research_and_generate_sections\u001b[0;34m(self, initial_findings, structure, query)\u001b[0m\n\u001b[1;32m    141\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msearch_system\u001b[38;5;241m.\u001b[39mmax_iterations \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m  \u001b[38;5;66;03m# Keep search focused\u001b[39;00m\n\u001b[1;32m    143\u001b[0m \u001b[38;5;66;03m# Perform search for this subsection\u001b[39;00m\n\u001b[0;32m--> 144\u001b[0m subsection_results \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msearch_system\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43manalyze_topic\u001b[49m\u001b[43m(\u001b[49m\u001b[43msubsection_query\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    146\u001b[0m \u001b[38;5;66;03m# Restore original iterations setting\u001b[39;00m\n\u001b[1;32m    147\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msearch_system\u001b[38;5;241m.\u001b[39mmax_iterations \u001b[38;5;241m=\u001b[39m original_max_iterations\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/search_system.py:152\u001b[0m, in \u001b[0;36mAdvancedSearchSystem.analyze_topic\u001b[0;34m(self, query)\u001b[0m\n\u001b[1;32m    140\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprogress_callback(\n\u001b[1;32m    141\u001b[0m     \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUsing search tool: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00msearch_tool\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m    142\u001b[0m     \u001b[38;5;241m1.5\u001b[39m,  \u001b[38;5;66;03m# Between setup and processing steps\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    148\u001b[0m     },\n\u001b[1;32m    149\u001b[0m )\n\u001b[1;32m    151\u001b[0m \u001b[38;5;66;03m# Use the strategy to analyze the topic\u001b[39;00m\n\u001b[0;32m--> 152\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstrategy\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43manalyze_topic\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquery\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    154\u001b[0m \u001b[38;5;66;03m# Update our attributes for backward compatibility\u001b[39;00m\n\u001b[1;32m    155\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstrategy, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mquestions_by_iteration\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/advanced_search_system/strategies/parallel_search_strategy.py:121\u001b[0m, in \u001b[0;36mParallelSearchStrategy.analyze_topic\u001b[0;34m(self, query)\u001b[0m\n\u001b[1;32m    116\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_update_progress(\n\u001b[1;32m    117\u001b[0m     \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGenerating search questions\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m10\u001b[39m, {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mphase\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mquestion_generation\u001b[39m\u001b[38;5;124m\"\u001b[39m}\n\u001b[1;32m    118\u001b[0m )\n\u001b[1;32m    120\u001b[0m \u001b[38;5;66;03m# Generate 3 additional questions (plus the main query = 4 total)\u001b[39;00m\n\u001b[0;32m--> 121\u001b[0m questions \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mquestion_generator\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate_questions\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    122\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcurrent_knowledge\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m  \u001b[49m\u001b[38;5;66;43;03m# No knowledge accumulation\u001b[39;49;00m\n\u001b[1;32m    123\u001b[0m \u001b[43m    \u001b[49m\u001b[43mquery\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mquery\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    124\u001b[0m \u001b[43m    \u001b[49m\u001b[43mquestions_per_iteration\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\n\u001b[1;32m    125\u001b[0m \u001b[43m        \u001b[49m\u001b[43mget_db_setting\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msearch.questions_per_iteration\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m    126\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m  \u001b[49m\u001b[38;5;66;43;03m# 3 additional questions\u001b[39;49;00m\n\u001b[1;32m    127\u001b[0m \u001b[43m    \u001b[49m\u001b[43mquestions_by_iteration\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    128\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    130\u001b[0m \u001b[38;5;66;03m# Add the original query as the first question\u001b[39;00m\n\u001b[1;32m    131\u001b[0m all_questions \u001b[38;5;241m=\u001b[39m [query] \u001b[38;5;241m+\u001b[39m questions\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/advanced_search_system/questions/standard_question.py:42\u001b[0m, in \u001b[0;36mStandardQuestionGenerator.generate_questions\u001b[0;34m(self, current_knowledge, query, questions_per_iteration, questions_by_iteration)\u001b[0m\n\u001b[1;32m     39\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m     40\u001b[0m     prompt \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m You will have follow up questions. First, identify if your knowledge is outdated (high chance). Today: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcurrent_time\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m. Generate \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mquestions_per_iteration\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m high-quality internet search questions to exactly answer: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mquery\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mFormat: One question per line, e.g. \u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m Q: question1 \u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m Q: question2\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m---> 42\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprompt\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     44\u001b[0m \u001b[38;5;66;03m# Handle both string responses and responses with .content attribute\u001b[39;00m\n\u001b[1;32m     45\u001b[0m response_text \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n",
      "File \u001b[0;32m~/git/local-deep-research/src/local_deep_research/config/llm_config.py:299\u001b[0m, in \u001b[0;36mwrap_llm_without_think_tags.<locals>.ProcessingLLMWrapper.invoke\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m    298\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21minvoke\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m--> 299\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbase_llm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    301\u001b[0m     \u001b[38;5;66;03m# Process the response content if it has a content attribute\u001b[39;00m\n\u001b[1;32m    302\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(response, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcontent\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/langchain_core/language_models/chat_models.py:307\u001b[0m, in \u001b[0;36mBaseChatModel.invoke\u001b[0;34m(self, input, config, stop, **kwargs)\u001b[0m\n\u001b[1;32m    296\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21minvoke\u001b[39m(\n\u001b[1;32m    297\u001b[0m     \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m    298\u001b[0m     \u001b[38;5;28minput\u001b[39m: LanguageModelInput,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    302\u001b[0m     \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs: Any,\n\u001b[1;32m    303\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m BaseMessage:\n\u001b[1;32m    304\u001b[0m     config \u001b[38;5;241m=\u001b[39m ensure_config(config)\n\u001b[1;32m    305\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m cast(\n\u001b[1;32m    306\u001b[0m         ChatGeneration,\n\u001b[0;32m--> 307\u001b[0m         \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate_prompt\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    308\u001b[0m \u001b[43m            \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_convert_input\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    309\u001b[0m \u001b[43m            \u001b[49m\u001b[43mstop\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    310\u001b[0m \u001b[43m            \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcallbacks\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    311\u001b[0m \u001b[43m            \u001b[49m\u001b[43mtags\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtags\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    312\u001b[0m \u001b[43m            \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmetadata\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    313\u001b[0m \u001b[43m            \u001b[49m\u001b[43mrun_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrun_name\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    314\u001b[0m \u001b[43m            \u001b[49m\u001b[43mrun_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpop\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mrun_id\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    315\u001b[0m \u001b[43m            \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    316\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mgenerations[\u001b[38;5;241m0\u001b[39m][\u001b[38;5;241m0\u001b[39m],\n\u001b[1;32m    317\u001b[0m     )\u001b[38;5;241m.\u001b[39mmessage\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/langchain_core/language_models/chat_models.py:843\u001b[0m, in \u001b[0;36mBaseChatModel.generate_prompt\u001b[0;34m(self, prompts, stop, callbacks, **kwargs)\u001b[0m\n\u001b[1;32m    835\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mgenerate_prompt\u001b[39m(\n\u001b[1;32m    836\u001b[0m     \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m    837\u001b[0m     prompts: \u001b[38;5;28mlist\u001b[39m[PromptValue],\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    840\u001b[0m     \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs: Any,\n\u001b[1;32m    841\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m LLMResult:\n\u001b[1;32m    842\u001b[0m     prompt_messages \u001b[38;5;241m=\u001b[39m [p\u001b[38;5;241m.\u001b[39mto_messages() \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;129;01min\u001b[39;00m prompts]\n\u001b[0;32m--> 843\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprompt_messages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcallbacks\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/langchain_core/language_models/chat_models.py:683\u001b[0m, in \u001b[0;36mBaseChatModel.generate\u001b[0;34m(self, messages, stop, callbacks, tags, metadata, run_name, run_id, **kwargs)\u001b[0m\n\u001b[1;32m    680\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(messages):\n\u001b[1;32m    681\u001b[0m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m    682\u001b[0m         results\u001b[38;5;241m.\u001b[39mappend(\n\u001b[0;32m--> 683\u001b[0m             \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_generate_with_cache\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    684\u001b[0m \u001b[43m                \u001b[49m\u001b[43mm\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    685\u001b[0m \u001b[43m                \u001b[49m\u001b[43mstop\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    686\u001b[0m \u001b[43m                \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_managers\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrun_managers\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m    687\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    688\u001b[0m \u001b[43m            \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    689\u001b[0m         )\n\u001b[1;32m    690\u001b[0m     \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m    691\u001b[0m         \u001b[38;5;28;01mif\u001b[39;00m run_managers:\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/langchain_core/language_models/chat_models.py:908\u001b[0m, in \u001b[0;36mBaseChatModel._generate_with_cache\u001b[0;34m(self, messages, stop, run_manager, **kwargs)\u001b[0m\n\u001b[1;32m    906\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m    907\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m inspect\u001b[38;5;241m.\u001b[39msignature(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_generate)\u001b[38;5;241m.\u001b[39mparameters\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrun_manager\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[0;32m--> 908\u001b[0m         result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_generate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    909\u001b[0m \u001b[43m            \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\n\u001b[1;32m    910\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    911\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m    912\u001b[0m         result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_generate(messages, stop\u001b[38;5;241m=\u001b[39mstop, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/langchain_openai/chat_models/base.py:955\u001b[0m, in \u001b[0;36mBaseChatOpenAI._generate\u001b[0;34m(self, messages, stop, run_manager, **kwargs)\u001b[0m\n\u001b[1;32m    953\u001b[0m     generation_info \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mheaders\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;28mdict\u001b[39m(raw_response\u001b[38;5;241m.\u001b[39mheaders)}\n\u001b[1;32m    954\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 955\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mpayload\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    956\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_chat_result(response, generation_info)\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/openai/_utils/_utils.py:279\u001b[0m, in \u001b[0;36mrequired_args.<locals>.inner.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m    277\u001b[0m             msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMissing required argument: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mquote(missing[\u001b[38;5;241m0\u001b[39m])\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m    278\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(msg)\n\u001b[0;32m--> 279\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py:914\u001b[0m, in \u001b[0;36mCompletions.create\u001b[0;34m(self, messages, model, audio, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, prediction, presence_penalty, reasoning_effort, response_format, seed, service_tier, stop, store, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, web_search_options, extra_headers, extra_query, extra_body, timeout)\u001b[0m\n\u001b[1;32m    871\u001b[0m \u001b[38;5;129m@required_args\u001b[39m([\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmessages\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmodel\u001b[39m\u001b[38;5;124m\"\u001b[39m], [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmessages\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmodel\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstream\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m    872\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mcreate\u001b[39m(\n\u001b[1;32m    873\u001b[0m     \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    911\u001b[0m     timeout: \u001b[38;5;28mfloat\u001b[39m \u001b[38;5;241m|\u001b[39m httpx\u001b[38;5;241m.\u001b[39mTimeout \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m|\u001b[39m NotGiven \u001b[38;5;241m=\u001b[39m NOT_GIVEN,\n\u001b[1;32m    912\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m ChatCompletion \u001b[38;5;241m|\u001b[39m Stream[ChatCompletionChunk]:\n\u001b[1;32m    913\u001b[0m     validate_response_format(response_format)\n\u001b[0;32m--> 914\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_post\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    915\u001b[0m \u001b[43m        \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/chat/completions\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m    916\u001b[0m \u001b[43m        \u001b[49m\u001b[43mbody\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmaybe_transform\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    917\u001b[0m \u001b[43m            \u001b[49m\u001b[43m{\u001b[49m\n\u001b[1;32m    918\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmessages\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    919\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodel\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    920\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43maudio\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43maudio\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    921\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfrequency_penalty\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrequency_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    922\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfunction_call\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunction_call\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    923\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfunctions\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunctions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    924\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlogit_bias\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogit_bias\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    925\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mlogprobs\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    926\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmax_completion_tokens\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_completion_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    927\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmax_tokens\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    928\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmetadata\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    929\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmodalities\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodalities\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    930\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mn\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    931\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mparallel_tool_calls\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mparallel_tool_calls\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    932\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mprediction\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprediction\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    933\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mpresence_penalty\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpresence_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    934\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mreasoning_effort\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mreasoning_effort\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    935\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mresponse_format\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mresponse_format\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    936\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mseed\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mseed\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    937\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mservice_tier\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mservice_tier\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    938\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstop\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    939\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstore\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstore\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    940\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstream\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    941\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mstream_options\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    942\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtemperature\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtemperature\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    943\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtool_choice\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtool_choice\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    944\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtools\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtools\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    945\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtop_logprobs\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_logprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    946\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtop_p\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_p\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    947\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43muser\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43muser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    948\u001b[0m \u001b[43m                \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mweb_search_options\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mweb_search_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    949\u001b[0m \u001b[43m            \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    950\u001b[0m \u001b[43m            \u001b[49m\u001b[43mcompletion_create_params\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mCompletionCreateParams\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    951\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    952\u001b[0m \u001b[43m        \u001b[49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmake_request_options\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    953\u001b[0m \u001b[43m            \u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mextra_headers\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra_query\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mextra_query\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra_body\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mextra_body\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtimeout\u001b[49m\n\u001b[1;32m    954\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    955\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcast_to\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mChatCompletion\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    956\u001b[0m \u001b[43m        \u001b[49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m    957\u001b[0m \u001b[43m        \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mStream\u001b[49m\u001b[43m[\u001b[49m\u001b[43mChatCompletionChunk\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    958\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/openai/_base_client.py:1242\u001b[0m, in \u001b[0;36mSyncAPIClient.post\u001b[0;34m(self, path, cast_to, body, options, files, stream, stream_cls)\u001b[0m\n\u001b[1;32m   1228\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mpost\u001b[39m(\n\u001b[1;32m   1229\u001b[0m     \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m   1230\u001b[0m     path: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m   1237\u001b[0m     stream_cls: \u001b[38;5;28mtype\u001b[39m[_StreamT] \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m   1238\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m ResponseT \u001b[38;5;241m|\u001b[39m _StreamT:\n\u001b[1;32m   1239\u001b[0m     opts \u001b[38;5;241m=\u001b[39m FinalRequestOptions\u001b[38;5;241m.\u001b[39mconstruct(\n\u001b[1;32m   1240\u001b[0m         method\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpost\u001b[39m\u001b[38;5;124m\"\u001b[39m, url\u001b[38;5;241m=\u001b[39mpath, json_data\u001b[38;5;241m=\u001b[39mbody, files\u001b[38;5;241m=\u001b[39mto_httpx_files(files), \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39moptions\n\u001b[1;32m   1241\u001b[0m     )\n\u001b[0;32m-> 1242\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m cast(ResponseT, \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrequest\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcast_to\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mopts\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream_cls\u001b[49m\u001b[43m)\u001b[49m)\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/openai/_base_client.py:919\u001b[0m, in \u001b[0;36mSyncAPIClient.request\u001b[0;34m(self, cast_to, options, remaining_retries, stream, stream_cls)\u001b[0m\n\u001b[1;32m    916\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m    917\u001b[0m     retries_taken \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[0;32m--> 919\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    920\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcast_to\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcast_to\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    921\u001b[0m \u001b[43m    \u001b[49m\u001b[43moptions\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    922\u001b[0m \u001b[43m    \u001b[49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    923\u001b[0m \u001b[43m    \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream_cls\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    924\u001b[0m \u001b[43m    \u001b[49m\u001b[43mretries_taken\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mretries_taken\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    925\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/openai/_base_client.py:955\u001b[0m, in \u001b[0;36mSyncAPIClient._request\u001b[0;34m(self, cast_to, options, retries_taken, stream, stream_cls)\u001b[0m\n\u001b[1;32m    952\u001b[0m log\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSending HTTP Request: \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m, request\u001b[38;5;241m.\u001b[39mmethod, request\u001b[38;5;241m.\u001b[39murl)\n\u001b[1;32m    954\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 955\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    956\u001b[0m \u001b[43m        \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    957\u001b[0m \u001b[43m        \u001b[49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_should_stream_response_body\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    958\u001b[0m \u001b[43m        \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    959\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    960\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m httpx\u001b[38;5;241m.\u001b[39mTimeoutException \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[1;32m    961\u001b[0m     log\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEncountered httpx.TimeoutException\u001b[39m\u001b[38;5;124m\"\u001b[39m, exc_info\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpx/_client.py:914\u001b[0m, in \u001b[0;36mClient.send\u001b[0;34m(self, request, stream, auth, follow_redirects)\u001b[0m\n\u001b[1;32m    910\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_set_timeout(request)\n\u001b[1;32m    912\u001b[0m auth \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_request_auth(request, auth)\n\u001b[0;32m--> 914\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_send_handling_auth\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    915\u001b[0m \u001b[43m    \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    916\u001b[0m \u001b[43m    \u001b[49m\u001b[43mauth\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mauth\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    917\u001b[0m \u001b[43m    \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    918\u001b[0m \u001b[43m    \u001b[49m\u001b[43mhistory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    919\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    920\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m    921\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m stream:\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpx/_client.py:942\u001b[0m, in \u001b[0;36mClient._send_handling_auth\u001b[0;34m(self, request, auth, follow_redirects, history)\u001b[0m\n\u001b[1;32m    939\u001b[0m request \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mnext\u001b[39m(auth_flow)\n\u001b[1;32m    941\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m--> 942\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_send_handling_redirects\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    943\u001b[0m \u001b[43m        \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    944\u001b[0m \u001b[43m        \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    945\u001b[0m \u001b[43m        \u001b[49m\u001b[43mhistory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhistory\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m    946\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    947\u001b[0m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m    948\u001b[0m         \u001b[38;5;28;01mtry\u001b[39;00m:\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpx/_client.py:979\u001b[0m, in \u001b[0;36mClient._send_handling_redirects\u001b[0;34m(self, request, follow_redirects, history)\u001b[0m\n\u001b[1;32m    976\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m hook \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_event_hooks[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrequest\u001b[39m\u001b[38;5;124m\"\u001b[39m]:\n\u001b[1;32m    977\u001b[0m     hook(request)\n\u001b[0;32m--> 979\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_send_single_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    980\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m    981\u001b[0m     \u001b[38;5;28;01mfor\u001b[39;00m hook \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_event_hooks[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mresponse\u001b[39m\u001b[38;5;124m\"\u001b[39m]:\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpx/_client.py:1014\u001b[0m, in \u001b[0;36mClient._send_single_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m   1009\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[1;32m   1010\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAttempted to send an async request with a sync Client instance.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m   1011\u001b[0m     )\n\u001b[1;32m   1013\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request\u001b[38;5;241m=\u001b[39mrequest):\n\u001b[0;32m-> 1014\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[43mtransport\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1016\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response\u001b[38;5;241m.\u001b[39mstream, SyncByteStream)\n\u001b[1;32m   1018\u001b[0m response\u001b[38;5;241m.\u001b[39mrequest \u001b[38;5;241m=\u001b[39m request\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpx/_transports/default.py:250\u001b[0m, in \u001b[0;36mHTTPTransport.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m    237\u001b[0m req \u001b[38;5;241m=\u001b[39m httpcore\u001b[38;5;241m.\u001b[39mRequest(\n\u001b[1;32m    238\u001b[0m     method\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mmethod,\n\u001b[1;32m    239\u001b[0m     url\u001b[38;5;241m=\u001b[39mhttpcore\u001b[38;5;241m.\u001b[39mURL(\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    247\u001b[0m     extensions\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mextensions,\n\u001b[1;32m    248\u001b[0m )\n\u001b[1;32m    249\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m map_httpcore_exceptions():\n\u001b[0;32m--> 250\u001b[0m     resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_pool\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreq\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    252\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(resp\u001b[38;5;241m.\u001b[39mstream, typing\u001b[38;5;241m.\u001b[39mIterable)\n\u001b[1;32m    254\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m Response(\n\u001b[1;32m    255\u001b[0m     status_code\u001b[38;5;241m=\u001b[39mresp\u001b[38;5;241m.\u001b[39mstatus,\n\u001b[1;32m    256\u001b[0m     headers\u001b[38;5;241m=\u001b[39mresp\u001b[38;5;241m.\u001b[39mheaders,\n\u001b[1;32m    257\u001b[0m     stream\u001b[38;5;241m=\u001b[39mResponseStream(resp\u001b[38;5;241m.\u001b[39mstream),\n\u001b[1;32m    258\u001b[0m     extensions\u001b[38;5;241m=\u001b[39mresp\u001b[38;5;241m.\u001b[39mextensions,\n\u001b[1;32m    259\u001b[0m )\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:256\u001b[0m, in \u001b[0;36mConnectionPool.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m    253\u001b[0m         closing \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_assign_requests_to_connections()\n\u001b[1;32m    255\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_close_connections(closing)\n\u001b[0;32m--> 256\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m exc \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m    258\u001b[0m \u001b[38;5;66;03m# Return the response. Note that in this case we still have to manage\u001b[39;00m\n\u001b[1;32m    259\u001b[0m \u001b[38;5;66;03m# the point at which the response is closed.\u001b[39;00m\n\u001b[1;32m    260\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response\u001b[38;5;241m.\u001b[39mstream, typing\u001b[38;5;241m.\u001b[39mIterable)\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/connection_pool.py:236\u001b[0m, in \u001b[0;36mConnectionPool.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m    232\u001b[0m connection \u001b[38;5;241m=\u001b[39m pool_request\u001b[38;5;241m.\u001b[39mwait_for_connection(timeout\u001b[38;5;241m=\u001b[39mtimeout)\n\u001b[1;32m    234\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m    235\u001b[0m     \u001b[38;5;66;03m# Send the request on the assigned connection.\u001b[39;00m\n\u001b[0;32m--> 236\u001b[0m     response \u001b[38;5;241m=\u001b[39m \u001b[43mconnection\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    237\u001b[0m \u001b[43m        \u001b[49m\u001b[43mpool_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrequest\u001b[49m\n\u001b[1;32m    238\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    239\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ConnectionNotAvailable:\n\u001b[1;32m    240\u001b[0m     \u001b[38;5;66;03m# In some cases a connection may initially be available to\u001b[39;00m\n\u001b[1;32m    241\u001b[0m     \u001b[38;5;66;03m# handle a request, but then become unavailable.\u001b[39;00m\n\u001b[1;32m    242\u001b[0m     \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[1;32m    243\u001b[0m     \u001b[38;5;66;03m# In this case we clear the connection and try again.\u001b[39;00m\n\u001b[1;32m    244\u001b[0m     pool_request\u001b[38;5;241m.\u001b[39mclear_connection()\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/connection.py:103\u001b[0m, in \u001b[0;36mHTTPConnection.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m    100\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connect_failed \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m    101\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m exc\n\u001b[0;32m--> 103\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_connection\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/http11.py:136\u001b[0m, in \u001b[0;36mHTTP11Connection.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m    134\u001b[0m     \u001b[38;5;28;01mwith\u001b[39;00m Trace(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mresponse_closed\u001b[39m\u001b[38;5;124m\"\u001b[39m, logger, request) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[1;32m    135\u001b[0m         \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_response_closed()\n\u001b[0;32m--> 136\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exc\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/http11.py:106\u001b[0m, in \u001b[0;36mHTTP11Connection.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m     95\u001b[0m     \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[1;32m     97\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\n\u001b[1;32m     98\u001b[0m     \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mreceive_response_headers\u001b[39m\u001b[38;5;124m\"\u001b[39m, logger, request, kwargs\n\u001b[1;32m     99\u001b[0m ) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[1;32m    100\u001b[0m     (\n\u001b[1;32m    101\u001b[0m         http_version,\n\u001b[1;32m    102\u001b[0m         status,\n\u001b[1;32m    103\u001b[0m         reason_phrase,\n\u001b[1;32m    104\u001b[0m         headers,\n\u001b[1;32m    105\u001b[0m         trailing_data,\n\u001b[0;32m--> 106\u001b[0m     ) \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_receive_response_headers\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    107\u001b[0m     trace\u001b[38;5;241m.\u001b[39mreturn_value \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m    108\u001b[0m         http_version,\n\u001b[1;32m    109\u001b[0m         status,\n\u001b[1;32m    110\u001b[0m         reason_phrase,\n\u001b[1;32m    111\u001b[0m         headers,\n\u001b[1;32m    112\u001b[0m     )\n\u001b[1;32m    114\u001b[0m network_stream \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_network_stream\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/http11.py:177\u001b[0m, in \u001b[0;36mHTTP11Connection._receive_response_headers\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m    174\u001b[0m timeout \u001b[38;5;241m=\u001b[39m timeouts\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mread\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m    176\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m--> 177\u001b[0m     event \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_receive_event\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    178\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(event, h11\u001b[38;5;241m.\u001b[39mResponse):\n\u001b[1;32m    179\u001b[0m         \u001b[38;5;28;01mbreak\u001b[39;00m\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_sync/http11.py:217\u001b[0m, in \u001b[0;36mHTTP11Connection._receive_event\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m    214\u001b[0m     event \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_h11_state\u001b[38;5;241m.\u001b[39mnext_event()\n\u001b[1;32m    216\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m event \u001b[38;5;129;01mis\u001b[39;00m h11\u001b[38;5;241m.\u001b[39mNEED_DATA:\n\u001b[0;32m--> 217\u001b[0m     data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_network_stream\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m    218\u001b[0m \u001b[43m        \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mREAD_NUM_BYTES\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtimeout\u001b[49m\n\u001b[1;32m    219\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    221\u001b[0m     \u001b[38;5;66;03m# If we feed this case through h11 we'll raise an exception like:\u001b[39;00m\n\u001b[1;32m    222\u001b[0m     \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[1;32m    223\u001b[0m     \u001b[38;5;66;03m#     httpcore.RemoteProtocolError: can't handle event type\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    227\u001b[0m     \u001b[38;5;66;03m# perspective. Instead we handle this case distinctly and treat\u001b[39;00m\n\u001b[1;32m    228\u001b[0m     \u001b[38;5;66;03m# it as a ConnectError.\u001b[39;00m\n\u001b[1;32m    229\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m data \u001b[38;5;241m==\u001b[39m \u001b[38;5;124mb\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_h11_state\u001b[38;5;241m.\u001b[39mtheir_state \u001b[38;5;241m==\u001b[39m h11\u001b[38;5;241m.\u001b[39mSEND_RESPONSE:\n",
      "File \u001b[0;32m~/git/local-deep-research/.venv/lib/python3.13/site-packages/httpcore/_backends/sync.py:128\u001b[0m, in \u001b[0;36mSyncStream.read\u001b[0;34m(self, max_bytes, timeout)\u001b[0m\n\u001b[1;32m    126\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m map_exceptions(exc_map):\n\u001b[1;32m    127\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sock\u001b[38;5;241m.\u001b[39msettimeout(timeout)\n\u001b[0;32m--> 128\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_sock\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrecv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmax_bytes\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/.pyenv/versions/3.13.2/lib/python3.13/ssl.py:1285\u001b[0m, in \u001b[0;36mSSLSocket.recv\u001b[0;34m(self, buflen, flags)\u001b[0m\n\u001b[1;32m   1281\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m flags \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m   1282\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m   1283\u001b[0m             \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnon-zero flags not allowed in calls to recv() on \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m\n\u001b[1;32m   1284\u001b[0m             \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m)\n\u001b[0;32m-> 1285\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbuflen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1286\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m   1287\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39mrecv(buflen, flags)\n",
      "File \u001b[0;32m~/.pyenv/versions/3.13.2/lib/python3.13/ssl.py:1140\u001b[0m, in \u001b[0;36mSSLSocket.read\u001b[0;34m(self, len, buffer)\u001b[0m\n\u001b[1;32m   1138\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sslobj\u001b[38;5;241m.\u001b[39mread(\u001b[38;5;28mlen\u001b[39m, buffer)\n\u001b[1;32m   1139\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m-> 1140\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_sslobj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1141\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m SSLError \u001b[38;5;28;01mas\u001b[39;00m x:\n\u001b[1;32m   1142\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m x\u001b[38;5;241m.\u001b[39margs[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m==\u001b[39m SSL_ERROR_EOF \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msuppress_ragged_eofs:\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "# Generate a comprehensive report\n",
    "report = generate_report(\n",
    "    \"impact of artificial intelligence on healthcare\",\n",
    "    iterations=1,\n",
    "    questions_per_iteration=1,\n",
    "    searches_per_section=1,\n",
    "    provider=\"openai_endpoint\",\n",
    "    model_name=\"llama-3.3-70b-instruct\",\n",
    "    openai_endpoint_url=\"https://api.ai.it.ufl.edu/v1/\",\n",
    "    search_tool=\"wikipedia\",\n",
    ")\n",
    "\n",
    "# Print report metadata\n",
    "print(\"Report metadata:\")\n",
    "for key, value in report[\"metadata\"].items():\n",
    "    print(f\"- {key}: {value}\")\n",
    "\n",
    "# Preview the first 500 characters of the report\n",
    "print(\"\\nReport preview:\")\n",
    "print(report[\"content\"][:500] + \"...\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Saving the Report to a File"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Save the report content to a file\n",
    "with open(\"ai_healthcare_report.md\", \"w\", encoding=\"utf-8\") as f:\n",
    "    f.write(report[\"content\"])\n",
    "\n",
    "print(\"Report saved to ai_healthcare_report.md\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Analyzing Local Documents\n",
    "\n",
    "If you have configured local document collections, you can search and analyze them:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Available collections:\n",
      "- project_docs: Project documentation and specifications\n",
      "- research_papers: Academic research papers and articles\n",
      "- personal_notes: Personal notes and documents\n"
     ]
    }
   ],
   "source": [
    "# Get a list of available collections\n",
    "from local_deep_research.api import get_available_collections\n",
    "\n",
    "collections = get_available_collections()\n",
    "print(\"Available collections:\")\n",
    "for name, config in collections.items():\n",
    "    print(f\"- {name}: {config.get('description', 'No description')}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Checking Available Search Engines"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from local_deep_research.api import get_available_search_engines\n",
    "\n",
    "engines = get_available_search_engines()\n",
    "print(\"Available search engines:\")\n",
    "for name, description in engines.items():\n",
    "    print(f\"- {name}: {description}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Advanced Usage: Setting Custom Search Parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Research with custom search settings\n",
    "advanced_summary = quick_summary(\n",
    "    query=\"latest climate change research\",\n",
    "    search_tool=\"auto\",  # Auto-select best search engine\n",
    "    iterations=2,  # Perform 2 research cycles\n",
    "    questions_per_iteration=3,  # 3 questions per cycle\n",
    "    max_results=50,  # Consider up to 50 search results\n",
    "    max_filtered_results=10,  # Keep 10 most relevant results\n",
    "    region=\"us\",  # US region focus\n",
    "    time_period=\"m\",  # Focus on last month\n",
    "    temperature=0.5,  # Lower temperature for more focused generation\n",
    ")\n",
    "\n",
    "print(f\"Research completed with {advanced_summary['iterations']} iterations\")\n",
    "print(\n",
    "    f\"Generated {sum(len(qs) for qs in advanced_summary['questions'].values())} questions\"\n",
    ")\n",
    "print(\"\\nSummary preview:\")\n",
    "print(advanced_summary[\"summary\"][:500] + \"...\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
